import { createRouter, createWebHistory , RouteRecordRaw} from 'vue-router'
import Home from '@/views/home/index.vue';
import { updateTitle } from '@/utils';

export const routes : Array<RouteRecordRaw> = [
    {
        path:'/',
        meta:{ // 很多信息都可以给meta里边放
            name:'首页',
            index:'index'
        },
        component:Home
    },
    {
        path:'/:catchMatch(.*)*',
        name:"NotFound",
        meta:{
            name:"NotFound",
            index:"NotFound"
        },
        component:() => import('@/not-found.vue')
    }
]

const router = createRouter({
    history:createWebHistory(),
    routes
})

router.beforeEach((to , from) => {
    // console.log(to, from);
    updateTitle(to.meta.name as string)
    return true
})

export default router